package cn.yuanqiao.web.controller.cqbc;
/**
 * @author 赵常飞
 * @date 2024/6/24 19:17
 */

import cn.yuanqiao.common.core.controller.BaseController;
import cn.yuanqiao.common.core.domain.R;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.core.page.TableDataInfo;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;
import cn.yuanqiao.cqbc.chuku.service.IChukuService;
import com.alibaba.fastjson2.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 *@Author: 赵常飞
 *@Date: 2024/6/24 19:17
 *@Description:
 *@Note:
 */
@RestController
@RequestMapping("/cqbc/chuku")
public class ChukuController extends BaseController {

    @Autowired
    private IChukuService chukuService;

    @Log(title = "获取分类存储树", businessType = BusinessType.SELECT)
    @GetMapping("/gettrees")
    public AjaxResult gettrees(){
        return success(chukuService.getTreeList());
    }

    @PostMapping("/getList")
    @Log(title = "获取列表数据", businessType = BusinessType.SELECT)
    public TableDataInfo getList(@RequestBody JSONObject json)
    {
        startPage();
        List<Map<String,Object>> list = chukuService.getList(json);
        return getDataTable(list);
    }
    @PostMapping("/fqsp")
    @Log(title = "发起审批", businessType = BusinessType.SUBMIT)
    public AjaxResult fqsp(@RequestBody JSONObject json)
    {
        int i = chukuService.fqsp(json);
        return success(i);
    }
    @Log(title = "长期保存出库鉴定办结", businessType = BusinessType.UPDATE)
    @PostMapping("/cqbcChukuBanjie")
    public R<Integer> cqbcChukuBanjie(@RequestBody Map<String,Object> map) {
        int i = chukuService.cqbcChukuBanjie(map);
        return R.ok(Integer.valueOf(i));
    }

    @Log(title = "长期保存删除鉴定审批流程不同意", businessType = BusinessType.UPDATE)
    @PostMapping("/killcqbcChuku")
    public AjaxResult killcqbcChuku(@RequestBody Map<String,Object> map) {
        chukuService.killcqbcChuku(map);
        return AjaxResult.success();
    }
    @Log(title = "长期保存下载出库包", businessType = BusinessType.DOWNLOAD)
    @PostMapping("/download/{id}")
    public void download(@PathVariable("id") Long id, HttpServletResponse response) throws IOException {
        chukuService.download(id,response);
    }
}
